# -*- coding: utf-8 -*-
import pygame
pygame.init()
pygame.font.init()
pygame.mixer.init()
pygame.mixer.pre_init(44100, -16, 2, 2048)
fpsClock = pygame.time.Clock()
surface = pygame.display.set_mode((800,600))
pygame.display.set_caption("Ex17.13")
background = pygame.Color( 0, 0, 0)
font = pygame.font.SysFont("Tahoma", 20)
text = font.render("Press 1, 2 or 3 to play sound No.1,2 or 3", True, (192,255,40))
running = True
while running:
    fpsClock.tick(30)
    surface.fill(background)
    surface.blit(text,(10, 10))
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_1:
                pygame.mixer.music.stop()
                pygame.mixer.music.load("./res/sounds/bell1.wav")
                pygame.mixer.music.play(0)
            elif event.key == pygame.K_2:
                pygame.mixer.music.stop()
                pygame.mixer.music.load("./res/sounds/bell2.wav")
                pygame.mixer.music.play(0)
            elif event.key == pygame.K_3:
                pygame.mixer.music.stop()
                pygame.mixer.music.load("./res/sounds/bell3.wav")
                pygame.mixer.music.play(0)
    pygame.display.flip()
pygame.font.quit()
pygame.quit()